home *** CD-ROM | disk | FTP | other *** search
- unit Unit1;
-
- interface
-
- uses
- Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
- StdCtrls, Spin;
-
- type
- TForm1 = class(TForm)
- btnStart: TButton;
- lstTimeResults: TListBox;
- Label1: TLabel;
- SpinEdit1: TSpinEdit;
- procedure btnStartClick(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
-
- var
- Form1: TForm1;
-
- implementation
-
- {$R *.DFM}
-
- uses DelDao;
-
- procedure TForm1.btnStartClick(Sender: TObject);
- var
- MyEng: TDDdbEngine;
- MyWs: TDDWorkspace;
- MyDB: TDDDatabase;
- MyRs: TDDRecordset;
- Tbl1: TDDTableDef;
- Fld1: TDDField;
- Fld2: TDDField;
- sT1, eT1: integer;
- s, e: integer;
- i: integer;
- begin
- try
- btnStart.Enabled := false;
-
- try
- MyEng := TDDdbEngine.Create; // this is done automatically in VB
-
- // start timer 1
- sT1 := GetTickCount;
- MyWs := MyEng.Workspaces[0];
-
- // create database
- // start timer 2
- s := GetTickCount;
- MyDB := MyWs.CreateDatabase('SpeedAriel.MDB', DAOdbLangGeneral, DAOdbVersion30);
- try
- Tbl1 := MyDB.CreateTableDef('Table1', 0, '', '');
- Fld1 := Tbl1.CreateField('IntField', DAOdbLong, 4);
- Fld1.Attributes := DAOdbAutoIncrField;
- Fld2 := Tbl1.CreateField('TextField', DAOdbText, 30);
- Tbl1.Fields.Append(Fld1);
- Tbl1.Fields.Append(Fld2);
- MyDb.TableDefs.Append(Tbl1);
- finally
- if assigned(Fld2) then
- Fld2.Free;
- if assigned(Fld1) then
- Fld1.Free;
- if assigned(Tbl1) then
- Tbl1.Free;
- end;
- e := GetTickCount;
- lstTimeResults.Items.Add('Created SpeedAriel.MDB: ' + IntToStr((e - s) div 1000));
- // end timer 2
-
- // fill data
- // start timer 3
- s := GetTickCount;
- try
- MyRs := MyDB.OpenRecordset('Table1', DAOdbOpenTable, 0);
- for i := 1 to SpinEdit1.Value do
- begin
- MyRs.AddNew;
- MyRs.Fields['TextField'].Value := 'Entry #' + IntToStr(i);
- MyRs.Update;
- end;
- MyRs.Close;
- finally
- if assigned(MyRs) then
- MyRs.Free;
- end;
- e := GetTickCount;
- lstTimeResults.Items.Add('Filled SpeedAriel.MDB: ' + IntToStr((e - s) div 1000));
- // end timer 3
-
- // forward navigation test
- // start timer 4
- s := GetTickCount;
- try
- MyRs := MyDB.OpenRecordset('Table1', DAOdbOpenTable, 0);
- while not MyRs.EOF do
- MyRs.MoveNext;
- MyRs.Close;
- finally
- if assigned(MyRs) then
- MyRs.Free;
- end;
- e := GetTickCount;
- lstTimeResults.Items.Add('Completed Forward Navigation Test: ' + IntToStr((e - s) div 1000));
- // end timer 4
-
- // backward navigation test
- // start timer 5
- s := GetTickCount;
- try
- MyRs := MyDB.OpenRecordset('Table1', DAOdbOpenTable, 0);
- MyRs.MoveLast;
- while not MyRs.BOF do
- MyRs.MovePrevious;
- MyRs.Close;
- finally
- if assigned(MyRs) then
- MyRs.Free;
- end;
- e := GetTickCount;
- lstTimeResults.Items.Add('Completed Backward Navigation Test: ' + IntToStr((e - s) div 1000));
- // end timer 5
-
- // end timer 1
- eT1 := GetTickCount;
-
- lstTimeResults.Items.Add('Total Time: ' + IntToStr((eT1 - sT1) div 1000));
- finally
- if assigned(MyDb) then
- MyDb.Free;
- if assigned(MyWs) then
- MyWs.Free;
- if assigned(MyEng) then
- MyEng.Free;
- end;
- finally
- btnStart.Enabled := true;
- end;
- end;
-
- end.
-